package com.tongcao.cn.util;


import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * @Author:tongcao
 * @Date:2018/11/9 11:34
 * Description:
 */
public final class Pair<K, V> {

    private K first;

    private V second;

    public Pair() {
    }

    public Pair(K first, V second) {
        this.first = first;
        this.second = second;
    }

    public K getFirst() {
        return first;
    }

    public void setFirst(K first) {
        this.first = first;
    }

    public V getSecond() {
        return second;
    }

    public void setSecond(V second) {
        this.second = second;
    }

    /**
     * JDK1.7可恶的泛型
     *
     * @param <K>
     * @param <V>
     * @return K, V
     */
    public static <K, V> Pair<K, V> newPair() {
        return new Pair<K, V>();
    }

    /**
     * @param <K>
     * @param <V>
     * @return
     */
    public static <K, V> Pair<K, V> newPair(K first, V second) {
        return new Pair<K, V>(first, second);
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
